<!doctype html>
<html lang="en">
<head>
    <script type="text/javascript" src=".././static/js/public-head.js"></script>

    <script>
        $(function() {

        })
    </script>
</head>

<body >
<div class="layui-inline">
    <div class="layui-input-inline">
        <input  type="text"   name="searchStr" id="searchStr" placeholder="输入关键字" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-input-inline" id="func-rpt-cfg">

    </div>
</div>
<hr>
<table class="layui-table" id="func-add-rpt-tab" lay-filter="func-add-rpt-tab"></table>

</body>
</html>

<script>
    var token = localStorage.getItem("token")
   layui.use("table",function(){
       var table = layui.table;
       var layer = layui.layer;
       var form = layui.form;
       table.render({
           id:"func-add-rpt-tab",
           elem: '#func-add-rpt-tab'
           ,url:basePath+'/function/getFuncCfgRptInfo'+urlParam
           ,where:{searchStr: function () {
               return $("#searchStr").val()
           } }
           ,cellMinWidth: 50 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
           ,page: false
           ,cols: [[
                { width: 50,  title: '选择',type:"radio" ,field:"id"}
               ,{field:'name', title: '名称' ,sort:"true"}
           ]]
           ,done:function(rst,curr,count){
               console.log(rst)
               var cfginfo =  typeof rst.cfgRpt
               if(cfginfo == "undefined" ||  $.isEmptyObject(rst.cfgRpt) ){
                   cfginfo = '&nbsp;已配置Report：无'
                   $("#func-rpt-cfg").html(cfginfo)
               }else{
                   cfginfo = '&nbsp;已配置Report：' + rst.cfgRpt.name
                   $("#func-rpt-cfg").html(cfginfo)
               }
           }
       });

       //监听单元格编辑
       table.on('radio(func-add-rpt-tab)', function(obj){
           var param = {rptId:obj.data.id}
           $.getJSON(basePath+"/function/funcAddRpt"+urlParam,param, function (rst) {
               if(rst.code !=0){
                    layer.alert(rst.msg)
               }
               table.reload("func-add-rpt-tab")
           })
       });

       $("#searchStr").bind('input propertychange', function() {
           table.reload("func-add-rpt-tab")
       });

   })
</script>


<script type="text/html" id="func-add-opt-state">
    <!-- 这里的 checked 的状态只是演示 -->
    <input type="checkbox" name="state"  _funcId="{{d.FUNCTION_ID}}" _optId="{{d.OPERATE_ID}}" _action="{{d.ACTION?d.ACTION:''}}"  _id="{{d.id}}"  value="{{d.STATE}}" lay-skin="switch" lay-text="是|否" lay-filter="filter-func-state" {{ d.STATE == 1 ? 'checked' : '' }}>
</script>